<extend name="Public/base" />
<block name="style">

</block>
<block name="body">

    <!-- 标题栏 -->
    <div class="main-title">
        <h2>用户列表</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <form action="" method="POST">
                手机号：<input type="text" name="phone" class="text input-2x" value="{$phone}" placeholder="手机号" />&nbsp; &nbsp;
                企业名称:<input type="text" name="company_name" class="text input-2x" value="{$company_name}" placeholder="企业名称">&nbsp; &nbsp;
                <button class="btn" type="submit">筛选</button>
            </form>
            <!--            <a class="btn" href="{:U('add')}">新 增</a>-->
            <!--            <button class="btn ajax-post confirm" url="{:U('changeStatus?method=deleteUser')}" target-form="ids">删 除</button>-->
        </div>
        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <!--<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>-->
        </div>
    </div>
    <div class="tab-wrap">
        <ul class="tab-nav nav">
            <li <?php if($_GET['tab'] == 1):?>class="current"<?php endif;?>><a href="{:U('index',array('tab'=>1))}">已通过</a></li>
            <li <?php if($_GET['tab'] == 0):?>class="current"<?php endif;?>><a href="{:U('index',array('tab'=>0))}">待审核</a></li>
            <li <?php if($_GET['tab'] == 2):?>class="current"<?php endif;?>><a href="{:U('index',array('tab'=>2))}">已拒绝</a></li>
        </ul>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
                <tr>
                    <th class="">用户ID</th>
                    <th class="">手机号</th>
                    <th class="">企业名称</th>
                    <?php if($tab == 1):?>
                     <th class="">账户余额</th>
                    <?php endif;?>
                    <th class="">企业联系人</th>
                    <th class="">企业电话</th>
                    <th class="">企业QQ</th>
                    <th class="">办公地址</th>
                    <th class="">营业执照</th>
                    <?php if($tab == 1):?>
                    <th class="">账户类型</th>
                    <th class="">用户状态</th>
                    <th class="">操作</th>
                    <?php elseif($tab == 2):?>
                    <th class="">拒绝原因</th>
                    <?php else:?>
                    <th class="">操作</th>
                    <?php endif;?>
                </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td>{$vo.company_user_id} </td>
                        <td>{$vo.company_user_phone}</td>
                        <td>{$vo.company_name}</td>
                        <?php if($tab == 1):?>
                        <td>￥{$vo.total_amount}</td>
                        <?php endif;?>
                        <td>{$vo.linkman}</td>
                        <td>{$vo.company_phone}</td>
                        <td>{$vo.qq}</td>
                        <td>{$vo.address}</td>
                        <td><img src="__ROOT__{$vo.company_licence_img}" class="read-img" style="width:80px;"></td>
                        <?php if($tab == 1):?>
                        <td><eq name="vo.is_root" value="1">主账号<else/>子账号</eq></th>

                    <td><eq name="vo['user_status']" value="1">禁用<else/>正常</eq></td>
                    <td>
                        <eq name="vo['user_status']" value="1">
                        <a href="{:U('edit',array('company_user_id'=>$vo['company_user_id'],'status'=>0))}" class="confirm ajax-get">启用</a>
                    <else />
                    <a href="{:U('edit',array('company_user_id'=>$vo['company_user_id'],'status'=>1))}" class="confirm ajax-get">禁用</a>
                    </eq>
                    <a href="javascript:;" data-id="{$vo['company_id']}" class="congzhi">账户充值</a>
                    </td>   
                    <?php elseif($tab == 2):?>
                    <td>{$vo.refund_desc}</td>
                    <?php else:?>
                    <td>
                        <a href="javascript:;" data-id="{$vo['company_id']}"  class="tongyi">同意</a>
                        &nbsp; 
                        <a href="javascript:;" data-id="{$vo['company_id']}" class="jujue">拒绝</a>
                    </td>   
                    <?php endif;?>

                    </tr>
                </volist>
                <else/>
                <td colspan="20" class="text-center"> aOh! 暂时还没有内容! </td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="page">
        {$_page}
    </div>
    <div class="show-box-back"  style="display: none;">
    </div>
    <!-- 审核通过框 -->
    <div class="show-box" id="js-tongguo" style="display: none;">
        <input type="hidden" name="company_id" id="js-tongguo-id">
        <input type="hidden" name="company_status" value="1">
        <div class="show-box-msg" >
            提示
        </div>
        <div class="show-box-msg-content">
            确认通过该用户吗
        </div>
        <div class="show-box-bottom">
            <button class="js-show-btn-cancel btn btn-return " >返 回</button>
            <button class="js-show-btn-ok btn submit-btn" id="submit-tongguo" >确 定</button>

        </div>
    </div>

    <!-- 审核拒绝框 -->
    <div class="show-box" id="js-jujue" style="display: none;">
        <input type="hidden" name="company_id" id="js-jujue-id">
        <input type="hidden" name="company_status" value="2">
        <div class="show-box-msg" >
            提示
        </div>
        <div class="show-box-msg-title">
            拒绝原因:
        </div>
        <div class="show-box-msg-area">
            <textarea class="show-box-msg-area" name="refund_desc" id="refund_desc" rows="3" cols="35"></textarea>
        </div>
        <div class="show-box-bottom">
            <button class="js-show-btn-cancel btn btn-return" >返 回</button>
            <button class="btn submit-btn" id="submit-jujue" >确 定</button>

        </div>
    </div>
    
    <!-- 充值 -->
    <div class="show-box" id="js-chongzhi" style="display: none;">
        <input type="hidden" name="company_id" id="js-chongzhi-id">
        <div class="show-box-msg" >
            账户充值
        </div>
        <div class="show-box-msg-item">
            本次充值金额: <input type="text" id="chongzhi-price" class="input-3x"> 元
        </div>

        <div class="show-box-bottom">
            <button class="js-show-btn-cancel btn btn-return" >返 回</button>
            <button class="btn submit-btn" id="submit-chongzhi" >确 定</button>

        </div>
    </div>
    
    <div class="show-box" id="js-tupian" style="display: none;">
        <img id="js-img" height="300" width="200">
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //搜索功能
        $(".tongyi").click(function () {
            var id = $(this).attr("data-id");
            $('#js-tongguo').show();
            $('.show-box-back').show();
            $('#js-tongguo-id').val(id);
        });
        //搜索功能
        $(".jujue").click(function () {
            var id = $(this).attr("data-id");
            $('#js-jujue').show();
            $('.show-box-back').show();
            $('#js-jujue-id').val(id);
        });
        $(".congzhi").click(function () {
            var id = $(this).attr("data-id");
            $('#js-chongzhi').show();
            $('.show-box-back').show();
            $('#js-chongzhi-id').val(id);
            $('#chongzhi-price').focus();
        });

        $("#submit-tongguo").click(function () {

            var id = $("#js-tongguo-id").val();
            $.post("{:U('edit')}", {company_id: id, company_status: 1}, function (res) {
                if (res.status) {
                    updateAlert('审核成功', 'alert-success');
                    setTimeout(function () {
                        location.reload();
                    }, 1500);
                }
            });
        });
        $("#submit-jujue").click(function () {
            var id = $("#js-jujue-id").val();
            var refund_desc = $("#refund_desc").val();
            $.post("{:U('edit')}", {company_id: id, company_status:2, refund_desc: refund_desc}, function (res) {
                if (res.status) {
                    updateAlert('审核成功', 'alert-success');
                    setTimeout(function () {
                        location.reload();
                    }, 1500);
                }
            });

        });
        
        $("#submit-chongzhi").click(function () {
            var id = $("#js-chongzhi-id").val();
            var total_amount = $("#chongzhi-price").val();
            $.post("{:U('chongzhi')}", {company_id: id, total_amount:total_amount}, function (res) {
                if (res.status) {
                    updateAlert('充值成功', 'alert-success');
                    setTimeout(function () {
                        location.reload();
                    }, 1500);
                }
            });

        });
        
        $(".read-img").click(function(){
           $('#js-tupian').show(); 
           $('.show-box-back').show();
           var imgsrc = $(this)[0].src; 
           $("#js-img").attr('src',imgsrc); 
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮

        highlight_subnav("{:U('CompanyUser/index',array('tab'=>1))}");
    </script>
</block>
